package decorator;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;

/**
 * 装饰器模式，是对继承的补充，在不改变原有对象的情况下动态给对象扩展功能，即插即用
 * 通过不同装饰器实现不同的效果
 * 遵守开闭原则
 * 会出现更多的代码，增加复杂性
 */
public class Test {
    private static Logger logger= LoggerFactory.getLogger(Test.class);
    public static void main(String[] args) {
        logger=new JsonLogger(logger);
        logger.info("系统测试");
        logger.error("系统错误");
        BatterCake batterCake=new BasebatterCake();
        System.out.println(batterCake.getMessage()+"价格"+batterCake.getPrice());
        batterCake=new EggDecorator(batterCake);
        System.out.println(batterCake.getMessage()+"价格"+batterCake.getPrice());
        batterCake=new SausageDecorator(batterCake);
        System.out.println(batterCake.getMessage()+"价格"+batterCake.getPrice());
        InputStream in= null;
        try {
            in = new FileInputStream("");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        BufferedInputStream bufferedInputStream=new BufferedInputStream(in);
        try {
            BufferedReader bufferedReader=new BufferedReader(new FileReader(""));
            bufferedReader.readLine();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
